﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="author" content="Aowork">
    <meta name="description" content="">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no">

    <title></title>

    <link href="../css/mobile.css" rel="stylesheet" />

    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
    <script src="../js/zepto.min.js"></script>
    <script src="../js/zepto.swipe.js"></script>
    <script src="../js/common.js"></script>
    <script src="../js/config.js"></script>
    <script src="../js/uiExtend.js"></script>
    <script src="../js/wx_config.js"></script>

    <script type="text/javascript">
        jc.fnInit.push(function () {
            jc.ui.header.trigger("updateTitle", "课程");
            jc.ui.header.trigger("updateNavCurrent", 1);
        });
    </script>

    <script type="text/javascript">
        var courseDetailsData = {
            grade: "",
            subject: "",
            subjectSeries:"",
            pageNo: 1,
            pageSize: 10,
            over: false
        }
    </script>

    <script type="text/javascript">


        if(jc.tools.getParam2("grade")){
            courseDetailsData.grade= decodeURIComponent(jc.tools.getParam2("grade"));
        }

        if(jc.tools.getParam2("subject")){
            courseDetailsData.subject= decodeURIComponent( jc.tools.getParam2("subject") );
        }

        if(jc.tools.getParam2("subjectSeries")){
            courseDetailsData.subjectSeries= decodeURIComponent(jc.tools.getParam2("subjectSeries"));
        }

        $.getJSON(window.path.gradeAndSubject,{}, function (result) {
            var filterTabData = [{
                    key: "全部专题",
                    value: "subjectSeries",
                    children: [{
                        key: "全部专题",
                        value: ""
                    }]
                },
                {
                    key: "全部年级",
                    value: "grade",
                    children: [{
                        key: "全部年级",
                        value: ""
                    }]
                },
                {
                    key: "全部科目",
                    value: "subject",
                    children: [{
                        key: "全部科目",
                        value: ""
                    }]
                },
            ];

            var data = result.data;


            for (var i = 0, l = data.subjectSeriesList.length; i < l; i++) {
                var cur = data.subjectSeriesList[i];

                var object = {};

                object.key = cur.name;
                object.value = cur.name;

                filterTabData[0].children.push(object);
            }

            for (var i = 0, l = data.gradeList.length; i < l; i++) {
                var cur = data.gradeList[i];

                var object = {};

                object.key = cur.name;
                object.value = cur.name;

                filterTabData[1].children.push(object);
            }



            for (var i = 0, l = data.subjectList.length; i < l; i++) {
                var cur = data.subjectList[i];

                var object = {};

                object.key = cur.name;
                object.value = cur.name;

                filterTabData[2].children.push(object);
            }


            jc.ui.filterTab.trigger("setup", filterTabData);

        });


        window.filterTabChange = function (data) {

            courseDetailsData.pageNo = 1;
            courseDetailsData.over = false;
            courseDetailsData.grade = data.grade;
            courseDetailsData.subject = data.subject;
            courseDetailsData.subjectSeries = data.subjectSeries;

            history.replaceState({},'',location.pathname + '?' +  "grade=" + data.grade + "&subject=" +  data.subject + "&subjectSeries=" + data.subjectSeries )

            updateCourseDetails();
        }
    </script>


    <script type="text/javascript">
        function updateCourseDetails() {
            $.getJSON(window.path.queryCourse, courseDetailsData, function (result) {
                if (result.success) {
                    jc.ui.courseHolder.filter("source=queryCourse", "setup", result.data.list);
                }
            });
        }
        updateCourseDetails();
    </script>


    <script type="text/javascript">
        window.onscroll = function () {
            var scrollTop = $(this).scrollTop();
            var scrollHeight = $(document).height();
            var windowHeight = $(this).height();
            if (scrollTop + windowHeight >= scrollHeight) {
                if (!window.courseDetailsData.over) {
                    window.courseDetailsData.pageNo = window.courseDetailsData.pageNo + 1;
                    $.get(window.path.queryCourse, window.courseDetailsData, function (result) {
                        if (!result.data.list.length) {
                            window.courseDetailsData.over = true;
                        }
                        jc.ui.courseHolder.trigger("append", result.data.list);
                    }, "json");
                }

            }
        }
    </script>

</head>

<body>

    <div data-ui="header" class="J_header hasLogo">
        <div class="h_inner"></div>
    </div>

    <div data-ui="filterTab" data-item-width="full" class="J_filterTab">
        <div class="f_inner">
        </div>
    </div>


    <div class="ptb10 bgfff bb1">

        <div data-ui="courseHolder" data-source="queryCourse" data-router="courseDetails/courseDetails.html" data-keyword="title,price,label,signAmount"
            class="J_courseHolder">
            <div class="c_inner">

            </div>
        </div>

    </div>



    <div data-ui="footer" class="J_footer">


    </div>


    <div data-ui="nav" class="J_nav">
        <div class="n_inner">
            <div class="i_center clearfix"></div>
        </div>
    </div>




</body>

</html>